package Demo;

public class Tank {
    public String name;
    public int shell = 50;//炮弹
    public int x;
    public int y;

    public Tank(String name, int x, int y) {//坦克构造方法
        this.name = name;
        this.x = x;
        this.y = y;
    }
    public void shang() {
        this.y = this.y + 1;
    }
    public void xia() {
        this.y = this.y - 1;
    }
    public void zuo() {
        this.x = this.x - 1;
    }
    public void you() {
        this.x = this.x + 1;
    }
    public void fire() { //开火
        this.shell = this.shell - 1;
    }
    public void getCoordinate() { //坐标
        System.out.println(this.name + "  坐标 x: " + x +" y:" + y);
    }
    public void getShell() {
        System.out.println(this.name +"炮弹剩余："+ shell);
    }
}
